package com.example.shushiyunsst.widget.verification.window;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by zhoulikai on 17/4/24.
 * 在当前页面的显示
 */

public class CurrentPageWindow implements IWindow {
    private ViewGroup parent;
    private View contentView;
    private Context context;

    public CurrentPageWindow(Context context) {
        this.context = context;
    }

    @Override
    public void windowCreate(int layoutId) {

    }

    @Override
    public void windowCreate(View contentView) {
        this.contentView = contentView;
    }

    @Override
    public void windowDestroy() {

    }

    @Override
    public void windowShow(View parent) {
        if (parent != null && parent instanceof ViewGroup) {
            this.parent = (ViewGroup) parent;
        }
        if (this.parent.getChildCount() == 0 && contentView != null) {
            ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            this.parent.addView(contentView, layoutParams);
            this.parent.setVisibility(View.VISIBLE);
        } else {
            this.parent.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void windowDismiss() {
//        if (this.parent != null) {
//            this.parent.setVisibility(View.GONE);
//        }

    }
}